package com.neucloud.da.edgeside.config;

import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class KubernetesConfig {

    @Value("${k8s.base.url}")
    String baseUrl;
    @Value("${k8s.cluster.token}")
    String token;


    @Bean("kubernetesClient")
    public KubernetesClient getClient() {
        Config config = new ConfigBuilder().withTrustCerts(true).withMasterUrl(baseUrl).withOauthToken(token).build();
        return new DefaultKubernetesClient(config);
    }
}
